<?php
// 圆形的类
class Round extends Shape {
    private $radius;
    const PI=3.14; //类里的常量调用需要用 self::PI
    function __construct($array=array()) {

        if(!empty($array)) {
            $this -> radius = $array['radius'];
        }
         $this -> name = "圆形";
    }

    function area() {
        return $this -> radius * $this -> radius * self::PI;
    }
    function girth() {
        return 2 * $this -> radius * self::PI;
    }
    function window() {
        $form = '<form action="main.php?action=round" method="post">';
        $form .= $this -> name.'的半径是：<input type="text" name="radius" value="'.$_POST['radius'].'" /><br />';
        $form .= '<input type="submit" name="dosubmit" value="计算"/><br />';
        $form .= '</form>';
        echo $form;
    }
    function verify($array) {
        $flag = true;
		if(!$array['radius'] ||$array['radius'] < 0) {
			echo $this->name."的半径不能小于0!<br>";
			$flag = false;
		}

		return $flag;
    }
}
